from zhoukao.Week3.Base import Base
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

class Page(Base):
    login_py = (By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    def login(self):
        self.click(self.login_py)
    #断言1：
    dy1_py = (By.XPATH,'//span[@class="reg-new"]')
    def dy1(self):
        self.text(self.dy1_py)
    #输入账号
    username_py = (By.NAME,'username')
    def username(self):
        self.send_keys(self.username_py)
    #输入密码
    password_py = (By.NAME,'password')
    def password(self):
        self.send_keys(self.password_py)
        #隐式等待
        self.driver.implicitly_wait(10)
    #点击登录
    djlogin_py = (By.CSS_SELECTOR,'.finish-btn')
    def djlogin(self):
        self.click(self.djlogin_py)
    #点击首页
    djsy_py = (By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a')
    def djsy(self):
        self.click(self.djsy_py)
    #点击商品
    djsp_py = (By.XPATH,'/html/body/div[8]/div[1]/div[2]/div[2]/ul/li[3]/div[2]/a')
    def djsp(self):
        self.click(self.djsp_py)
    #点击立即购买
    djljgm_py = (By.ID,'buy-cart')
    def djljgm(self):
        self.click(self.djljgm_py)
    #勾选收获地址
    gxshdz_py = (By.TAG_NAME,'address_id')
    def gxshdz(self):
        self.click(self.gxshdz_py)
    #点击支付方式
    djzffs_py = (By.XPATH,'//*[@id="theForm"]/div[3]/div[2]/div[1]/label/input')
    def djzffs(self):
        self.click(self.djzffs_py)
    # #点击下一步
    djnext_py = (By.XPATH,'//*[@id="order-button"]')

    # djxyb_py = (By.LINK_TEXT,'下一步')

    def djxyb(self):
        self.click(self.djnext_py)

    def test_01_A3mall(self):
        #输入网址
        self.get_url('http://10.59.9.12:7001/')
        #点击输入网址
        self.login()
        #断言会员登录
        print(self.dy1())
        #输入账号密码
        self.username()
        self.password()
        #强制等待
        sleep(10)
        self.djlogin()
        #点击首页
        self.djsy()
        #点击商品
        self.djsp()
        #点击立即购买
        self.djljgm()
        #勾选收货地址
        self.gxshdz()
        #点击支付方式
        self.djzffs()
        #点击下一步
        self.djxyb()




